package com.ensah.web.mb;

import java.util.*;
import javax.annotation.PostConstruct;

import com.ensah.bo.Book;
import com.ensah.services.BookService;


public class BookController {
	private Book book = new Book();
	private List<Book> bookList = new ArrayList<Book>();
	private BookService bookService;

	public BookController() {
	}

	@PostConstruct
	public void populate() {
		bookList = bookService.getAllBooks();
	}

	public String doNew() {
		return "newBook.xhtml";
	}

	public String doCreateBook() {
		bookService.addNewBook(book);
		bookList = bookService.getAllBooks();
		return "/pages/listBooks.xhtml";
	}

	public Book getBook() {
		return book;
	}

	public void setBook(Book book) {
		this.book = book;
	}

	public List<Book> getBookList() {
		return bookList;
	}

	public void setBookList(List<Book> bookList) {
		this.bookList = bookList;
	}

	public BookService getBookService() {
		return bookService;
	}

	public void setBookService(BookService bookService) {
		this.bookService = bookService;
	}
}